package pub.guoxin.oops.common.protocol.adapter;

import lombok.Getter;
import lombok.Setter;
import pub.guoxin.oops.common.protocol.builder.DataProtocolTypeRegister;
import pub.guoxin.oops.common.protocol.entity.map.DataProtocolTypeMap;

/**
 * Created by guoxin on 18-3-8.
 */
@Getter
@Setter
public abstract class AbstractDataProtocolTypeAdapter {

    private DataProtocolTypeMap dataProtocolTypeMap = DataProtocolTypeMap.newDataProtocolTypeMap();

    public abstract DataProtocolTypeRegister register(DataProtocolTypeRegister register);

    private DataProtocolTypeRegister register0(DataProtocolTypeRegister register) {
        DataProtocolTypeRegister register1 = register(register);
        this.dataProtocolTypeMap.putAll(register1.getRegister());
        return register1;
    }

    public DataProtocolTypeMap build() {
        this.register0(new DataProtocolTypeRegister());
        return dataProtocolTypeMap;
    }
}
